package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Objects;

@Entity
public class Contract {
    private int contractId;
    private Long cMoney;
    private String cPayment;
    private Timestamp starttime;
    private Timestamp endtime;
    private String contractstate;
    private String contractdesc;
    private Long crApprover;
    private String ecrState;
    private String contractName;
    private String contractNumber;
    private Customer customerId;
    private Linkman linkId;
    private Sales sales2;
    private Employee employee;
    private Employee employee2;
    private Long oursigner;
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "cr_approver",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee2() {
        return employee2;
    }

    public void setEmployee2(Employee employee2) {
        this.employee2 = employee2;
    }

    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "oursigner",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    @Basic
    @Column(name = "oursigner")
    public Long getOursigner() {
        return oursigner;
    }

    public void setOursigner(Long oursigner) {
        this.oursigner = oursigner;
    }

    @OneToOne //JPA注释： 一对一 关系
    @JoinColumn(name="SALES_ID2" )// 在pepole中，添加一个外键 "pet_fk"
    public Sales getSales2() {
        return sales2;
    }

    public void setSales2(Sales sales2) {
        this.sales2 = sales2;
    }


    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name="customer_id")//设置在article表中的关联字段(外键)
    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name="link_id")//设置在article表中的关联字段(外键)
    public Linkman getLinkId() {
        return linkId;
    }

    public void setLinkId(Linkman linkId) {
        this.linkId = linkId;
    }

    @Basic
    @Column(name = "contract_name")
    public String getContractName() {
        return contractName;
    }

    public void setContractName(String contractName) {
        this.contractName = contractName;
    }
    @Basic
    @Column(name = "contract_number")
    public String getContractNumber() {
        return contractNumber;
    }

    public void setContractNumber(String contractNumber) {
        this.contractNumber = contractNumber;
    }

    @Id
    @Column(name = "contract_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public int getContractId() {
        return contractId;
    }

    public void setContractId(int contractId) {
        this.contractId = contractId;
    }

    @Basic
    @Column(name = "c_money")
    public Long getcMoney() {
        return cMoney;
    }

    public void setcMoney(Long cMoney) {
        this.cMoney = cMoney;
    }

    @Basic
    @Column(name = "c_payment")
    public String getcPayment() {
        return cPayment;
    }

    public void setcPayment(String cPayment) {
        this.cPayment = cPayment;
    }

    @Basic
    @Column(name = "starttime")
    public Timestamp getStarttime() {
        return starttime;
    }

    public void setStarttime(Timestamp starttime) {
        this.starttime = starttime;
    }

    @Basic
    @Column(name = "endtime")
    public Timestamp getEndtime() {
        return endtime;
    }

    public void setEndtime(Timestamp endtime) {
        this.endtime = endtime;
    }


    @Basic
    @Column(name = "contractstate")
    public String getContractstate() {
        return contractstate;
    }

    public void setContractstate(String contractstate) {
        this.contractstate = contractstate;
    }

    @Basic
    @Column(name = "contractdesc")
    public String getContractdesc() {
        return contractdesc;
    }

    public void setContractdesc(String contractdesc) {
        this.contractdesc = contractdesc;
    }

    @Basic
    @Column(name = "cr_approver")
    public Long getCrApprover() {
        return crApprover;
    }

    public void setCrApprover(Long crApprover) {
        this.crApprover = crApprover;
    }

    @Basic
    @Column(name = "ecr_state")
    public String getEcrState() {
        return ecrState;
    }

    public void setEcrState(String ecrState) {
        this.ecrState = ecrState;
    }


}
